package com.balance.anole.client.retail.payment;

import java.math.BigDecimal;

import com.balance.anole.common.to.CodeLookTO;
import com.balance.anole.erp.util.NumberUtil;
import com.balance.anole.utils.Constants;

public class BankPayment extends Payment {

	public BankPayment(BigDecimal paid, BigDecimal needPay) {
		super(paid, needPay);
		setPaymentMode(new CodeLookTO(Constants.CODE_TYPE_PAYMENT_TYPE, "B"));
	}

	public BigDecimal pay(){
		return paid.subtract(needPay);
	}

	public boolean isValid(){
		boolean result = false;
		if((result = super.isValid()) && pay().signum() > 0){
			setPaymentValidationMsg("卡付(" + NumberUtil.formatMoney(paid) + ")不能超过所需金额：" + NumberUtil.formatMoney(needPay) + ".");
			result = false;
		}
		return result;
	}

	public int getPriority(){
		return 50;
	}

	@Override
	public String getPaymentDesc() {
		return "卡付";
	}

	@Override
	public BigDecimal getRealPaidValue() {
		//paid by bank: no change.
		return paid;
	}

}
